#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;

int tt;
int n, m, lm, vm;
int cnt;
int d[maxn], v[maxn], a[maxn];
int p[maxn];
int x[maxn];

inline int f(int vt, int v0, int a){
    return (vt*vt - v0*v0) / 2*a;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);

    cin >> tt;
    for(int i = 0; i < tt; i++){
        cin >> n >> m >> lm >> vm;
        cnt = 0;
        for(int j = 0; j < n; j++){
            cin >> d[j] >> v[j] >> a[j];
            if(!a[j]){
                if(v[j] <= vm) x[j] = 10*maxn;
                else x[j] = 0;
            }else x[j] = f(vm, v[j], a[j]);
        }

        int temp;
        for(int j = 0; j < m; j++){
            cin >> p[j];
            temp = j;
        }

        for(int j = 0; j < n; ++j){
            if(d[j] + x[j] <= p[temp]) ++cnt;
        }
        cout << cnt << ' ';
        if(cnt) cout << m - 1 << endl;
        else cout << m << endl;
    }

	fclose(stdin);
	fclose(stdout);
	return 0;
}
